package cn.itsource.ldj.base.controller;

import cn.itsource.ldj.base.service.ICodeService;
import cn.itsource.ldj.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private ICodeService codeService;

    @PostMapping("/sendCode")
    public AjaxResult sendCode(@RequestBody Map<String, String> map) {
        try {
            codeService.sendCode(map);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMsg(e.getMessage());
        }
    }
}
